package br.com.escolaespacocrianca.fineec.model;

import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import br.com.escolaespacocrianca.fineec.model.enums.GenderType;


@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "enrollmentNumber" })) 
public class Student extends BaseEntity {
	
	private String name;
	
	private Integer enrollmentNumber;
	
	private GenderType gender;
	private GregorianCalendar birthday;
	private String nacionality;
	private String citizenship;
	
	@OneToOne
	@Cascade(value={CascadeType.REFRESH})
	private Sponsor firstSponsor;
	
	@OneToOne
	@Cascade(value={CascadeType.REFRESH})
	private Sponsor secondSponsor;
	
	@OneToOne
	@Cascade(value={CascadeType.REFRESH})
	private Sponsor financialSponsor;
	
	@OneToOne
	@Cascade(value={CascadeType.ALL})
	private Address address;
	
	@OneToMany
	@Cascade(value={CascadeType.ALL})
	private List<OtherSponsor> otherSponsors;
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public GenderType getGender() {
		return gender;
	}

	public void setGender(GenderType gender) {
		this.gender = gender;
	}

	public String getNacionality() {
		return nacionality;
	}

	public void setNacionality(String nacionality) {
		this.nacionality = nacionality;
	}

	public String getCitizenship() {
		return citizenship;
	}

	public void setCitizenship(String citizenship) {
		this.citizenship = citizenship;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public Sponsor getFirstSponsor() {
		return firstSponsor;
	}

	public void setFirstSponsor(Sponsor firstSponsor) {
		this.firstSponsor = firstSponsor;
	}

	public Sponsor getSecondSponsor() {
		return secondSponsor;
	}

	public void setSecondSponsor(Sponsor secondSponsor) {
		this.secondSponsor = secondSponsor;
	}

	public List<OtherSponsor> getOtherSponsors() {
		return otherSponsors;
	}

	public void setOtherSponsors(List<OtherSponsor> otherSponsors) {
		this.otherSponsors = otherSponsors;
	}

	public Sponsor getFinancialSponsor() {
		return financialSponsor;
	}

	public void setFinancialSponsor(Sponsor financialSponsor) {
		this.financialSponsor = financialSponsor;
	}

	public GregorianCalendar getBirthday() {
		return birthday;
	}

	public void setBirthday(GregorianCalendar birthday) {
		this.birthday = birthday;
	}
	
	public String getBirthdayString() {
		SimpleDateFormat a = new SimpleDateFormat("dd/MM/yyyy");
		
		
		
		return a.format(birthday.getGregorianChange());
	}

	public Integer getEnrollmentNumber() {
		return enrollmentNumber;
	}

	public void setEnrollmentNumber(Integer enrollmentNumber) {
		this.enrollmentNumber = enrollmentNumber;
	}

}
